/****************************************************************************
  @file    : regedit.c
  @Version : V1.0
  @Company : NULL
  @author  : wandeng
  @date    : 2024-6-21
  @brief   :
*****************************************************************************/

/* Includes ----------------------------------------------------------------*/
#include "regedit.h"

/* Private typedef ---------------------------------------------------------*/
/* Private define ----------------------------------------------------------*/
#define AIRCON_REMOTE_START_NUM         0x01     //空调遥控器起始编号
#define TVBOX_REMOTE_START_NUM          0x40     //电视遥控器起始编号
#define OTHER_REMOTE_START_NUM          0x80     //其他遥控器起始编号
      
#define AIRCON_REMOTE_NUM               40       //支持空调遥控数
#define TVBOX_REMOTE_NUM                30       //支持电视遥控数
#define OTHER_REMOTE_NUM                1        //支持其他遥控数

/* Private macro -----------------------------------------------------------*/
/* Private function prototypes ---------------------------------------------*/
static void NullIrPackage (void *);

//空调遥控器红外帧组包函数
extern void GreeYAD0FIrPackage    (void *);
extern void MideaRM05IrPackage    (void *);
extern void GreeYB0F2IrPackage    (void *);
extern void GreeY502KIrPackage    (void *);
extern void TCLGYKQ47IrPackage    (void *);
extern void HisenseHYCW01KIrPackage (void *);
extern void MHN502A064IrPackage   (void *);
extern void HAIERIrPackage      (void *);
extern void YORKIrPackage     (void *);
extern void X13IrPackage      (void *);
extern void BRC4L165IrPackage   (void *);
extern void YKR_H801IrPackage   (void *);
extern void ZHJT03IrPackage     (void *);
extern void HitachiPCLH7QKIrPackage (void *);
extern void YORK05IrPackage     (void *);
extern void WHL11SEIrPackage    (void *);
extern void RM12A_BGFIrPackage    (void *);
extern void AR_RAF1CIrPackage   (void *);
extern void GYKQ_03IrPackage    (void *);
extern void YORK_RD03IrPackage    (void *);
extern void MideaRN02CAIrPackage  (void *);
extern void McQuarIrPackage     (void *);
extern void YORK03IrPackage     (void *);
extern void EK135BIrPackage     (void *);
extern void BRC4C158IrPackage   (void *);
extern void Haier2IrPackage     (void *);
extern void XiaoMiIrPackage     (void *);
extern void HitachiPCLH6QKIrPackage (void *);
extern void GreeYAP0FIrPackage  (void *);
extern void MideaRN02CA6IrPackage(void *);
extern void HisenseEKY_H1IrPackage(void *);
extern void NT03IrPackage       (void *);
extern void Haier3IrPackage     (void *p);

//电视遥控器红外帧组包函数
extern void MiBoxIrPackage      (void *);
extern void TMBoxIrPackage      (void *);
extern void XSHUAIIrPackage     (void *);
extern void W2540IrPackage      (void *);
extern void TVBox73IrPackage    (void *);
extern void HaierHTRA07BIrPackage (void *);
extern void TVBox76IrPackage    (void *);
extern void TCLBoxIrPackage     (void *);
extern void TelecomIrPackage    (void *);
extern void TCL_PJIrPackage     (void *);
extern void TelecomYDIrPackage  (void *);
extern void konkaYDIrPackage    (void *);
extern void Hisense83IrPackage  (void *);
extern void TVBox84IrPackage    (void *);
extern void TVBox85IrPackage    (void *);
extern void TVBox86IrPackage    (void *);
extern void Hisense87IrPackage  (void *);
extern void TVBox88IrPackage    (void *);
extern void TVBox89IrPackage    (void *);
extern void TVBox90IrPackage    (void *);
extern void TVBox91IrPackage    (void *);
extern void CN3A17_92_IrPackage (void *);
extern void TVBox93IrPackage    (void *);

//其他遥控器红外帧组包函数
extern void benqIrPackage     (void *);

/* Private variables -------------------------------------------------------*/
/* Public variables --------------------------------------------------------*/
REMOTEDEV RemoteDev[10] = {//遥控器状态管理
  {0,TYPE_UNDEF,NullIrPackage},
  {0,TYPE_UNDEF,NullIrPackage},
  {0,TYPE_UNDEF,NullIrPackage},
  {0,TYPE_UNDEF,NullIrPackage},
  {0,TYPE_UNDEF,NullIrPackage},
  {0,TYPE_UNDEF,NullIrPackage},
  {0,TYPE_UNDEF,NullIrPackage},
  {0,TYPE_UNDEF,NullIrPackage},
  {0,TYPE_UNDEF,NullIrPackage},
  {0,TYPE_UNDEF,NullIrPackage},
};             

/* Private functions -------------------------------------------------------*/
//空调遥控器红外帧组包函数注册表
static IRPackageFun  AirCon_IRPackageFunRegister[AIRCON_REMOTE_NUM] = {
  GreeYAD0FIrPackage,         // 1  格力空调遥控器(型号YAD0F)
  MideaRM05IrPackage,         // 2  美的空调遥控器(型号RM05/BG(T)-A )
  GreeYB0F2IrPackage,         // 3  格力空调遥控器(型号YB0F2 )
  GreeY502KIrPackage,         // 4  格力空调遥控器(型号Y502K )
  TCLGYKQ47IrPackage,         // 5  TCL空调遥控器 (型号GYKQ-47)
  NullIrPackage,            // 6  科龙遥控器
  NullIrPackage,            // 7  LG2遥控器
  NullIrPackage,            // 8  富士通空调遥控器
  HisenseHYCW01KIrPackage,      // 9  海信空调遥控器(型号HYC-W01)
  MHN502A064IrPackage,        // 10 三菱重工海尔空调遥控器(型号MHN502A064)
  HAIERIrPackage,           // 11 海尔空调遥控器
  YORKIrPackage,            // 12 约克(YORK)遥控器(定制)
  X13IrPackage,           // 13 X13
  BRC4L165IrPackage,          // 14 大金空调遥控器(型号BRC4L165)
  YKR_H801IrPackage,          // 15 奥克斯空调遥控器(型号YKR-H/801)
  ZHJT03IrPackage,          // 16 志高空调遥控器(型号ZH/JT-03)
  HitachiPCLH7QKIrPackage,      // 17 HITACHI空调遥控器(型号PC-LH7Q)
  YORK05IrPackage,          // 18 YORK05
  WHL11SEIrPackage,         // 19 东芝(WH-L11SE)
  NullIrPackage,            // 20 
  NullIrPackage,            // 21 
  RM12A_BGFIrPackage,         // 22 玉屏楼宾馆(黄山)
  AR_RAF1CIrPackage,          // 23
  NullIrPackage,            // 24 
  GYKQ_03IrPackage,         // 25 TCL河南骏秋
  YORK_RD03IrPackage,         // 26 约克RD-03 河南骏秋
  MideaRN02CAIrPackage,       // 27 美的RN02CA1
  McQuarIrPackage,          // 28 麦克维尔MCGS01
  YORK03IrPackage,          // 29 TICA(呼和浩特-影巢)
  EK135BIrPackage,          // 30 EK135B
  MHN502A064IrPackage,        // 31 三菱重工海尔 MHN502A081
  BRC4C158IrPackage,          // 32 大金空调遥控器(型号BRC4C158)
  Haier2IrPackage,          // 33 HAIER遥控器
  XiaoMiIrPackage,          // 34 米家空调
  HitachiPCLH6QKIrPackage,  // 35 日立遥控器
  GreeYAP0FIrPackage,       //格力空调遥控器(型号YAP0F)
  MideaRN02CA6IrPackage,    // 37 美的RN02CA6
  HisenseEKY_H1IrPackage,   // 38 海信EKY_H1
  NT03IrPackage,            //山寨志高遥控器 NT-03
  Haier3IrPackage,          // 40 海尔遥控器
};

//电视遥控器红外帧组包函数注册表
static IRPackageFun  TVBox_IRPackageFunRegister[TVBOX_REMOTE_NUM] = {
  XSHUAIIrPackage,      // 64 小帅投影遥控器
  W2540IrPackage,       // 65 明基 W2540 投影仪遥控  开关  65 开 1 关 2
  MiBoxIrPackage,       // 66 小米遥控器
  NullIrPackage,        // 67 
  TMBoxIrPackage,       // 68 天猫魔盒遥控器
  NullIrPackage,        // 69 
  NullIrPackage,        // 70 
  NullIrPackage,        // 71 
  NullIrPackage,        // 72 
  TVBox73IrPackage,     // 73 
  HaierHTRA07BIrPackage,    // 74 
  NullIrPackage,        // 75 
  TVBox76IrPackage,     // 76 
  TCLBoxIrPackage,      // 77 TCL 机顶盒
  TelecomIrPackage,     // 78 中国电信
  TCL_PJIrPackage,      // 79 TCL普杰
  TelecomYDIrPackage,     // 80 福建泉州云朵酒店机顶盒
  konkaYDIrPackage,     // 81 福建泉州云朵酒店电视机
  benqIrPackage,        // 82 BenQ投影仪
  Hisense83IrPackage,     // 83 
  TVBox84IrPackage,     // 84 成都锦城原舍
  TVBox85IrPackage,     // 85 瑞丝汀-Haier
  TVBox86IrPackage,     // 86 PHILIPS
  Hisense87IrPackage,   // 87 海信 CN2V27
  TVBox88IrPackage,     // 88 电信机顶盒
  TVBox89IrPackage,     // 89 夏普（RRMCGB246WJSA2）
  TVBox90IrPackage,     // 90 移动机顶盒
  TVBox91IrPackage,     // 91 
  CN3A17_92_IrPackage,  // 92 海信CN3A17
  TVBox93IrPackage,     // 93 盐城金陵饭店对接遥控器 类似海信机顶盒&三星遥控器开关键
};


//其他遥控器红外帧组包函数注册表
static IRPackageFun  Other_IRPackageFunRegister[OTHER_REMOTE_NUM] = {
  NullIrPackage,      //InFocus投影仪遥控器
};

/* Public functions --------------------------------------------------------*/
void RemoteSelect(uint8_t n,uint8_t num) {
  if(n >= 10) return;
  if(num == RemoteDev[n].Num) return ;

  if(num == 0) {
    RemoteDev[n].Num = 0;
    RemoteDev[n].Type = TYPE_UNDEF;
    RemoteDev[n].Package = NullIrPackage; 
  }

  if(num < AIRCON_REMOTE_START_NUM + AIRCON_REMOTE_NUM) {
    RemoteDev[n].Num = num;
    RemoteDev[n].Type = TYPE_AIRCON;
    RemoteDev[n].Package = AirCon_IRPackageFunRegister[num-AIRCON_REMOTE_START_NUM];
  } else if(num < TVBOX_REMOTE_START_NUM + TVBOX_REMOTE_NUM) {
    RemoteDev[n].Num = num;
    RemoteDev[n].Type = TYPE_TVBOX;
    RemoteDev[n].Package = TVBox_IRPackageFunRegister[num-TVBOX_REMOTE_START_NUM];
  } else if(num < OTHER_REMOTE_START_NUM + OTHER_REMOTE_NUM) {
    RemoteDev[n].Num = num;
    RemoteDev[n].Type = TYPE_OTHER;
    RemoteDev[n].Package = Other_IRPackageFunRegister[num-OTHER_REMOTE_START_NUM];
  }
}

static void NullIrPackage (void *ptr) {
  (void *) ptr;
}
